﻿<Page
    x:Class="Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Views.Favourites"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:converters="using:Microsoft.ALMRangers.VsarTreasureMap.WindowsStoreApp.Converters"
    mc:Ignorable="d">
    <Page.Resources>
        <converters:CountToVis x:Key="countToVis"/>
    </Page.Resources>
    <Page.TopAppBar>
        <AppBar>
            <StackPanel Orientation="Horizontal">
                <Button Command="{Binding GoToHome}" Content="Home" Style="{StaticResource AppBarTextButtonStyle}" FontSize="26.667" Margin="40,0,0,0"/>
            </StackPanel>
        </AppBar>
    </Page.TopAppBar>

    <Grid Background="{StaticResource BackgroundBrush}">
        <Grid.RowDefinitions>
            <RowDefinition Height="120"/>
            <RowDefinition Height="20"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <Grid Grid.Row="0">
            <Grid.ColumnDefinitions>
                <ColumnDefinition Width="140"/>
                <ColumnDefinition  Width="*"/>
            </Grid.ColumnDefinitions>
            <Button Command="{Binding GoBack}" Grid.Column="0" Style="{StaticResource BackButtonStyle}"  Margin="0,32,0,0" VerticalAlignment="Center" HorizontalAlignment="Center" />
            <TextBlock Grid.Column="1" x:Uid="/Content/YourFavouriteProjects" Style="{StaticResource PageHeaderTextStyle}" Text="Your Favourite Projects" Margin="0,0,0,20" FontFamily="{StaticResource TitleFont}" Foreground="{StaticResource TitleBrush}" />
        </Grid>
        <Grid Grid.Row="2" Margin="120,0,0,0">
            <Grid Visibility="{Binding Projects.Count, Converter={StaticResource countToVis}}">
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto" />
                    <RowDefinition Height="30"/>
                    <RowDefinition Height="Auto" />
                </Grid.RowDefinitions>
                <TextBlock Grid.Row="0" x:Uid="/Content/NoFavouriteMessage" Text="You have no favourites for projects - try adding some with the appbar. See example image below:" Style="{StaticResource BasicTextStyle}" />
                <Image Grid.Row="2" x:Uid="/Content/FavouriteHintImage" MaxHeight="300" HorizontalAlignment="Left" Source="ms-appx:///Assets/AddAsFavourite.png" />
            </Grid>
            <ListView ItemsSource="{Binding Projects}" VerticalAlignment="Stretch" Tapped="ListView_Tapped" ItemContainerStyle="{StaticResource ListViewItemStyle}" KeyUp="ListView_KeyUp">
                <ListView.ItemTemplate>
                    <DataTemplate>
                        <StackPanel>
                            <TextBlock Text="{Binding Name}" Style="{StaticResource SubheaderTextStyle}">
                                <TextBlock.Foreground>
                                    <SolidColorBrush Color="{StaticResource Title}"/>
                                </TextBlock.Foreground>
                            </TextBlock>
                            <TextBlock Text="{Binding Description}" TextWrapping="Wrap" Style="{StaticResource SubtitleTextStyle}"/>
                        </StackPanel>
                    </DataTemplate>
                </ListView.ItemTemplate>
            </ListView>
        </Grid>
    </Grid>
</Page>